#include <retro.h>
#include "retro.creator.h"

using namespace Retro::Creator::Dialog;

VOID    EditMap::addHeader(INT cxMax, INT cyMax)
{
  addEdit(hEditName, lblName, _T("Name:"));
  addSeparator(sepName);

  addNumeric(hUpDownWidth, hEditWidth, lblWidth, _T("Width: "),
    RETRO_MAP_MINWIDTH,
    cxMax,
    RETRO_MAP_MINWIDTH);

  addNumeric(hUpDownHeight, hEditHeight, lblHeight, _T("Height: "),
    RETRO_MAP_MINHEIGHT,
    cyMax,
    RETRO_MAP_MINHEIGHT);

  addNumeric(hUpDownLayers, hEditLayers, lblLayers, _T("Layers: "),
    RETRO_MAP_MINLAYERS,
    RETRO_MAP_MAXLAYERS,
    RETRO_MAP_MINLAYERS);
}

VOID    EditMap::addFooter()
{
  addOKCancel(btnOK, btnCancel, sepButtons);
}

VOID    EditMap::onNotify(Event::NotifyEvent& iEvent)
{
  switch (iEvent.data->idFrom)
  {
  case IDOK:
    if (GetWindowTextLength(hEditName) == 0)
    {
      MessageBox(*this, _T("Name cannot be empty"), NULL, MB_ICONERROR);
    }
    else
    {
      setResult(DialogOK);
    }
  case IDCANCEL:
    hide();
    break;
  }
}
